<template>
  <section>
  	<div class="model">
  		<img :src="IMGBASE64.BANJIFUDAO2X" class="orange">
  		<span class="title">班级辅导</span>
  		<div class="kong"></div>
  		<template>
  			<el-table :data="tablemsg">
    			<!-- <el-table-column prop="coachId" label="#" min-width="80" align="center"></el-table-column> -->
  				<el-table-column prop="studentName" label="姓名" min-width="150" align="center"></el-table-column>
    			<el-table-column prop="subject" label="辅导课程" min-width="150" align="center"></el-table-column>
    			<el-table-column prop="teacherName" label="辅导老师" min-width="150" align="center"></el-table-column>
    			<el-table-column prop="coachTimestr" label="辅导时间" min-width="200" align="center"></el-table-column>
    			<el-table-column prop="cPhone" label="联系方式" min-width="150" align="center"></el-table-column>
    			<el-table-column prop="coachResult" label="辅导情况" :show-overflow-tooltip='true'></el-table-column>
  			</el-table>
        <el-pagination
          v-show="paging"
          @current-change="handleCurrentChange"
          :page-size="20"
          layout="prev, pager, next, jumper"
          :total="total"
          class="pull-right">
        </el-pagination>
  		</template>
  	</div>
  </section>
</template>

<script>
export default {
  data () {
    return {
      total: 0,
      page: 1,
      paging: true,
      tablemsg: [{
        num: '1',
        name: '李俊义',
        course: '数学',
        teacher: '欧阳俊逸',
        time: '2015/09/15 13:00:00',
        phone: '13622222222',
        situation: '辅导前一个月的知识点'
      },
      {
        num: '2',
        name: '李俊义',
        course: '数学',
        teacher: '欧阳俊逸',
        time: '2015/09/15 13:00:00',
        phone: '13622222222',
        situation: '辅导前一个月的知识点'
      },
      {
        num: '3',
        name: '李俊义',
        course: '数学',
        teacher: '欧阳俊逸',
        time: '2015/09/15 13:00:00',
        phone: '13622222222',
        situation: '辅导前一个月的知识点'
      }]
    }
  },
  mounted () {
    // let _cookie = document.cookie.split(';')
    // let _cookieArray = []
    // _cookie.forEach(v => {
    //   let _d = v.split('=')
    //   _cookieArray.push({
    //     key: _d[0],
    //     value: _d[1]
    //   })
    // })
    this.xtoken = localStorage.xtoken
    this.$http.post(this._httpUrl + 'course/coach/classCoach', {}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
      if (response.body.code === '000') {
        // console.log(response.data.data)
        this.tablemsg = response.data.data.content
        for (var i = 0; i < this.tablemsg.length; i++) {
          if (this.tablemsg[i].fatherMobile == null) {
            this.tablemsg.cPhone = this.tablemsg[i].motherMobile
          } else if (this.tablemsg[i].motherMobile == null) {
            this.tablemsg.cPhone = this.tablemsg[i].fatherMobile
          } else {
            this.tablemsg[i].cPhone = this.tablemsg[i].fatherMobile
          }
        }
      } else if (response.body.code === '887') {
        this.$router.push('/')
      } else if (response.body.code === '889') {
        this.$router.push('/')
      }
    })
  },
  methods: {
    handleCurrentChange (val) {
      this.page = val
      // let _cookie = document.cookie.split(';')
      // let _cookieArray = []
      // _cookie.forEach(v => {
      //   let _d = v.split('=')
      //   _cookieArray.push({
      //     key: _d[0],
      //     value: _d[1]
      //   })
      // })
      this.$http.post(this._httpUrl + 'course/coach/classCoach', {}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          // console.log(response.data.data)
          this.tablemsg = response.data.data.content
          for (var i = 0; i < this.tablemsg.length; i++) {
            if (this.tablemsg[i].fatherMobile == null) {
              this.tablemsg.cPhone = this.tablemsg[i].motherMobile
            } else if (this.tablemsg[i].motherMobile == null) {
              this.tablemsg.cPhone = this.tablemsg[i].fatherMobile
            } else {
              this.tablemsg[i].cPhone = this.tablemsg[i].fatherMobile
            }
          }
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
	.model{
		width: 98%;
		position: relative;
		background: #FFF;
		margin-left: 1%;
		margin-top: 60px;
		border-radius: 5px;
		padding-top: 10px;
		.orange{
			position: absolute;
			left: 2%;
			top: -25px;
		}
		.title{
			margin-left: 11%;
		}
	}
  .kong{
  	padding: 20px;
  }
</style>
